package com.xjl.user.enums;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public enum ChannelEnum {

    DOU_YIN(0,"抖音渠道"),
    BILIBILI(1,"B站渠道");

    private Integer code;

    private String message;

    ChannelEnum(int code,String message){
        this.code=code;
        this.message=message;
    }

    public Integer getCode(){
        return this.code;
    }

    public String getMessage(){
        return this.message;
    }

    public static final Map<Integer,ChannelEnum> channelEnumMap = Stream.of(ChannelEnum.values())
            .collect(Collectors.toMap(i->i.getCode(),i->i));

    /**
     * 根据code获取枚举
     * @param code
     * @return
     */
    public static ChannelEnum getEnumByCode(Integer code){
        return channelEnumMap.get(code);
    }
}
